<script setup lang="ts">
import {
  ElAlert,
  ElCard,
  ElSpace,
  ElIcon,
  ElRow,
  ElCol,
  ElStatistic,
  ElTooltip
} from 'element-plus'
import { ContentWrap } from '@/components/ContentWrap'
import { useI18n } from '@/hooks/web/useI18n'
import { ref } from 'vue'
import { Icon } from '@/components/Icon/index'

defineOptions({
  name: 'Servers'
})

const { t } = useI18n()

const text = ref('')
</script>

<template>
  <ContentWrap title="服务器">
    <el-alert title="功能需求1：集群所有服务器信息" type="error" :closable="false" />
    <el-row :gutter="16" style="margin: 80px 0">
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic :value="4">
            <template #title>
              <div style="display: inline-flex; align-items: center"> 总服务器数量 </div>
            </template>
          </el-statistic>
          <div class="statistic-footer">
            <div class="footer-item">
              <span>空闲服务器</span>
              <span class="green">
                4
                <el-icon>
                  <CaretTop />
                </el-icon>
              </span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic :value="32">
            <template #title>
              <div style="display: inline-flex; align-items: center"> 总GPU数量 </div>
            </template>
          </el-statistic>
          <div class="statistic-footer">
            <div class="footer-item">
              <span>空闲GPU数量</span>
              <span class="red">
                32
                <el-icon>
                  <CaretBottom />
                </el-icon>
              </span>
            </div>
          </div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="statistic-card">
          <el-statistic :value="30" title="New transactions today">
            <template #title>
              <div style="display: inline-flex; align-items: center"> 总存储容量(PB) </div>
            </template>
          </el-statistic>
          <div class="statistic-footer">
            <div class="footer-item">
              <span>剩余容量</span>
              <span class="green">
                16%
                <el-icon>
                  <CaretTop />
                </el-icon>
              </span>
            </div>
            <div class="footer-item">
              <el-icon :size="14">
                <ArrowRight />
              </el-icon>
            </div>
          </div>
        </div>
      </el-col>
    </el-row>

    <el-row :gutter="20">
      <el-col :span="6" v-for="o in 4" :key="o">
        <el-card style="width: 100%">
          <template #header>
            <div class="card-header">
              <span>Server {{ o }}</span>
            </div>
          </template>
          <el-space spacer="|">
            <span> <Icon icon="solar:cpu-bold" /> 192</span>
            <span> <Icon icon="oui:memory" /> 2TB</span>
            <span> <Icon icon="bi:gpu-card" /> H100 x 8</span>
          </el-space>
          <!-- <template #footer>Footer content</template> -->
        </el-card>
      </el-col>
    </el-row>
  </ContentWrap>
</template>
<style scoped>
:global(h2#card-usage ~ .example .example-showcase) {
  background-color: var(--el-fill-color) !important;
}

.el-statistic {
  --el-statistic-content-font-size: 28px;
}

.statistic-card {
  height: 100%;
  padding: 20px;
  background-color: var(--el-bg-color-overlay);
  border: 1px solid #ccc;
  border-radius: 4px;
}

.statistic-footer {
  display: flex;
  margin-top: 16px;
  font-size: 12px;
  color: var(--el-text-color-regular);
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.statistic-footer .footer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.statistic-footer .footer-item span:last-child {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
}

.green {
  color: var(--el-color-success);
}

.red {
  color: var(--el-color-error);
}
</style>
